import java.util.ArrayList;
import java.util.List;

/**
 * @author Sebastian
 * @version 2.0
 * @date 2024/8/7 10:34
 */
//后序遍历
    //https://leetcode.cn/problems/binary-tree-postorder-traversal/description/
public class Solution145 {
    List<Integer> res = new ArrayList<Integer>();
    public List<Integer> postorderTraversal(TreeNode root) {
        afOrder(root);
        return res;
    }
    private void afOrder(TreeNode root) {
        if (root == null) return;
        afOrder(root.left);
        afOrder(root.right);
        res.add(root.val);
    }
}
